package com.hlwxy.ssm.quartz;

import com.hlwxy.ssm.model.SystemUser;
import com.hlwxy.ssm.service.DingTalkService;
import com.hlwxy.ssm.service.SystemUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

//spring Spring可以扫描到并初始化
@Component
public class TimingTask {

    @Autowired
    private DingTalkService dingTalkService;

   /* @Scheduled(cron = "0/59 * *  * * ?")  //配置定时任务的执行时间
    public  void nowTime() {
       // System.out.println("查询新消息 " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ").format(new Date()));
    }*/

    //  https://blog.csdn.net/zalan01408980/article/details/80555492
   //  0 0 1 * * ?  每天凌晨1点执行一次

    @Scheduled(cron = "0 0 1 * * ?")  //配置定时任务的执行时间
    public  void getSystemUser() {
         dingTalkService.getAllDataBy3();
        //System.out.println("查询新消息 " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ").format(new Date()));
    }
}
